package org.syx.edl.validate;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.math.BigDecimal;

/**
 * @author:whh
 * @date: 2025-09-05 22:34
 * <p></p>
 */
public class FixDecimalValidator implements ConstraintValidator<FixDecimal, BigDecimal> {
    private int require;
    @Override
    public void initialize(FixDecimal constraintAnnotation) {
        this.require=constraintAnnotation.scale();
    }
    @Override
    public boolean isValid(BigDecimal val, ConstraintValidatorContext constraintValidatorContext) {
        if(val==null)return false;
        return require==val.scale();
    }
}
